﻿using UnityEngine;

namespace Jinndev {

    public class UIFollowUI : MonoBehaviour {

        public RectTransform targetTransform;
        public Vector2 offset;

        private RectTransform rectTransform;

        private void Awake() {
            rectTransform = GetComponent<RectTransform>();
        }

        private void Update() {
            if (targetTransform == null) {
                return;
            }
            rectTransform.position = targetTransform.position + new Vector3(offset.x, offset.y, 0);
        }

        public void SetTarget(GameObject obj) {
            targetTransform = obj.GetComponent<RectTransform>();
        }

    }

}
